package com.example.message.web;

import com.example.message.config.ExpireMessage;
import com.example.message.config.RabbitMQConfig;
import org.junit.Test;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.UUID;

/**
 * @author 小许
 * @Title:
 * @Package
 * @Description:
 * @date 2020/11/24-19:07
 */
@RestController
public class SendMessageController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("/sendMessage")
    public void sendMessage(@RequestParam String orderNo) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.DELAY_QUEUE, (Object) orderNo,
                new ExpireMessage(1000 * 60 * 5 + ""));
        System.out.println("我发送了" + new Date().toString() + ".." + orderNo);
    }
}
